package com.acme.bankapp.domain.accounts;

import java.io.Serializable;

import com.acme.bankapp.domain.Client;
import com.acme.bankapp.exceptions.NegativeAmountException;
import com.acme.bankapp.exceptions.NotEnoughFundsException;

/**
 * 
 * Holds balance info.
 * Ensures safety of business rules.
 *
 */
public abstract class AbstractAccount implements Account, Serializable{
	//TODO proper init
	protected static int nextId = 0;
	
	protected AccountType accountType;
	protected double balance;
	protected Client client;
	
	protected int id;
	
	protected static int updateNextId() {
		return nextId++;
	}

	public abstract boolean withdraw(double amount) throws NotEnoughFundsException, NegativeAmountException;

	public abstract boolean deposit(double amount) throws NegativeAmountException;

	public double getBalance() {
		return balance;
	}

	public AccountType getAccountType(){
		return accountType;
	};
	
	public abstract long decimalValue();	  

	public void setClient(Client client) {
		this.client = client;
	}

	public int getId() {
		return id;
	}

}
